package org.performancetracker;

import org.performancetracker.api.Tracker;
import org.performancetracker.api.Aggregator;

/**
 * Basic factory for the trackers.
 *
 * Uses the jar linked class TrackerFactoryImpl class to create the trackers.
 * Any implementation should define it's own TrackerFactoryImpl class.
 *
 * @author: jaronschut
 */

public abstract class TrackerFactory {

	public static final String TRACKER_FACTORY_IMPLEMENTATION = TrackerFactory.class.getName();

	private static TrackerFactoryImpl TRACKER_FACTORY = new FactoryHelper<TrackerFactoryImpl>()
				.instantiate(TrackerFactoryImpl.class, TRACKER_FACTORY_IMPLEMENTATION);

	/**
     * Create a Tracker with root trackeraggregator.
     * Used by performancetracker itself to log events.
     *
     * @return
     */
    public static final Tracker startTracker() {
        return TRACKER_FACTORY.createTracker().start();
    }

    /**
     * Create a tracker with a specific tracker aggregator.
     * In this implementation this is the name of the slf4j logger.
     *
     * @param aggregator
     * @return
     */
    public static final Tracker startTracker(Aggregator aggregator) {
        return TRACKER_FACTORY.createTracker(aggregator).start();
    }

	/**
	 * Return the class name of thefactory used to create the trackers.
	 *
	 * @return
	 */
	public static final TrackerFactoryImpl getTrackerFactory() {
		return TRACKER_FACTORY;
	}

	/**
	 * Return the factory used to create the trackers.
	 *
	 * @return
	 */
	public static final String getTrackerFactoryImplementation() {
		return TRACKER_FACTORY_IMPLEMENTATION;
	}
}